def solve(n, m):
a = list(map(int, input().split()))
lastCorrectPos = n - 1
while lastCorrectPos >= 0 and a[lastCorrectPos] == lastCorrectPos + 1:
lastCorrectPos -= 1
ans = 1.0
if lastCorrectPos == -1:
ans = 0.0
for _ in range(m):
data = input().split()
r = int(data[0]) - 1
p = float(data[1])
if r >= lastCorrectPos:
ans = ans * (1 - p)
print("{:.6f}".format(1 - ans))
t = int(input())
for _ in range(t):
data = input().split()
solve(int(data[0]), int(data[1]))
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
#define inp(x) freopen(x".inp", "r", stdin);
#define out(x) freopen(x".out", "w", stdout);
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define bit(i,x) (x>>i)&1
#define fou(i, a, b) for(int i=a;i<=b;++i)
#define fod(i, a, b) for(int i=a;i>=b;--i)
const ll e=1e9+7;
const ll inf=1e18;
const int nmax=2e5;
const int base=311;
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
// inp("");
// out("");
cout<<fixed<<setprecision(6);
int test;
cin>>test;
while(test--){
int n, m;
cin>>n>>m;
int a[n+1];
fou(i,1,n) cin>>a[i];
int h=n;
while(h>=1 && a[h]==h) h--;
long double ans=h>0;
while(m--){
int r; long double p;
cin>>r>>p;
if(r>=h) ans*=(1-p);
} ans=1-ans;
cout<<ans<<endl;
}
return 0;
}
2144. Minimum Cost of Buying Candies With Discount | Non empty subsets |
1630A - And Matching | 1630B - Range and Partition |
1630C - Paint the Middle | 1630D - Flipping Range |
1328A - Divisibility Problem | 339A - Helpful Maths |
4A - Watermelon | 476A - Dreamoon and Stairs |
1409A - Yet Another Two Integers Problem | 977A - Wrong Subtraction |
263A - Beautiful Matrix | 180C - Letter |
151A - Soft Drinking | 1352A - Sum of Round Numbers |
281A - Word Capitalization | 1646A - Square Counting |
266A - Stones on the Table | 61A - Ultra-Fast Mathematician |
148A - Insomnia cure | 1650A - Deletions of Two Adjacent Letters |
1512A - Spy Detected | 282A - Bit++ |
69A - Young Physicist | 1651A - Playoff |
734A - Anton and Danik | 1300B - Assigning to Classes |
1647A - Madoka and Math Dad | 710A - King Moves |